
#ifndef EDGEMERGEBOARD_H
#define EDGEMERGEBOARD_H

#include <BMesh>
#include <BGeometry>

#include <BLabel>
#include <BButton>
#include <BRealSpinBox>
#include <BProgressBar>

#include <BDialog>

using namespace BWE;

class EdgeMergeBoard : public BDialog
{
	BOBJECT(EdgeMergeBoard)
public:
	EdgeMergeBoard(BWidget* parent = 0);
	~EdgeMergeBoard();

protected:
	int closestIndex(int index, BReal limit);

protected:
	void slotAssetChanged(BObject* object, const BValue& value);
	void slotDistanceLimitEditFinished(BObject* object, const BValue& value);
	void slotRefreshButtonToggled(BObject* object, const BValue& value);
	void slotApplyButtonClicked(BObject* object, const BValue& value);
	void slotCancelButtonClicked(BObject* object, const BValue& value);

protected:
	virtual void showEvent(const BEvent& event);
	virtual void hideEvent(const BEvent& event);
	virtual void updateEvent(const BEvent& event);

private:
	BLabel*				_originVertexNumberLabel;
	BLabel*				_newVertexNumberLabel;
	BLabel*				_minEdgeLengthLabel;
	BRealSpinBox*		_distanceLimitSpinBox;
	BButton*			_refreshButton;
	BProgressBar*		_progressBar;
	BLabel*				_informationLabel;

	BButton*			_applyButton;
	BButton*			_cancelButton;
	
	int						_currentIndex;
	BHolder<BVectorArray>	_vertices;
	BHolder<BVectorArray>	_normals;
	BHolder<BColorArray>	_colors;
	BHolder<BCoordArray>	_texCoords;
	BVectorArray*			_newVertices;
	BVectorArray*			_newNormals;
};

#endif
